package com.lanxin.xxform.mappers;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.lanxin.xxform.beans.Subject;
import com.lanxin.xxform.tools.JetCriteria;

@Mapper
public interface SubjectMapper {

    @Insert("insert into subject (pid,subtitle,options,type,checked,uid) values (${pid},#{subtitle},#{options},${type},${checked},${uid})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insert(Subject subject);

    @Select("select * from subject where id=${id}")
    Subject find(long id);

    @Select("select count(*) from subject ${condition}")
    int count(JetCriteria criteria);

    @Select("select ${select} from subject ${fullCondition}")
    List<Subject> findAll(JetCriteria criteria);

    @Update("update subject set subtitle=#{subtitle},options=#{options},type=${type},checked=${checked} where id=${id}")
    int update(Subject subject);

    @Delete("delete from subject where id=${id}")
    int delete(long id);
    
}
